<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <title>商务策划复制</title>
</head>
<style>
	.fieldset{
		margin-top: 5px;
		margin-bottom: 0px
	}
	.layui-legend{
		background-color:#5fb878;
		font-size:15px !important;
		width:140px;
	}
	.layui-form-item {
	    margin-bottom: 5px;
	    clear: both;
	    *zoom: 1;
	}
	.layui-form-label{width: 160px;}
	.right{
		float:right;
	}
	.width106{
		width:106px;
	}
	.width98{
		width:98px;
	}
	.width60{
		width:60px;
	}
</style>
<body>
<div class="layui-fluid">
    <div class="layui-card">
	    <div class="layui-tab-item layui-show">
	    	<div style="padding-top:15px;">&nbsp;</div>
			<form class="layui-form" id="addInfo_form" lay-filter="add_info_from">
				<fieldset class="layui-elem-field layui-field-title fieldset"  id="baseInfo">
				  <legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">项目基础信息  ></legend>
				  <div style="margin-top:20px">
				  	<div class="layui-form-item">
				  		<div class="layui-inline">
					      	<label class="layui-form-label">申请公司</label>
					      	<div class="layui-input-inline">
					      		<input type="hidden" name="effectOrgId" value="${bindOrgId}">
								<input type="text" value="${bindOrgName}" style="border:0px;" readonly="readonly" class="layui-input">
					      	</div>
					    </div>
					    <div class="layui-inline">
					    	<label class="layui-form-label">申请部门</label>
				      		<div class="layui-input-inline">
				      			<input type="hidden" name="effectDeptId" value="${bindDeptId}">
								<input type="text" value="${bindDeptName}" style="border:0px;" readonly="readonly" class="layui-input">
				      		</div>
					    </div>
					    <div class="layui-inline">
					    	<label class="layui-form-label">申请人</label>
				      		<div class="layui-input-inline">
				        		<input type="hidden" name="effectStaffApplyId" readonly="readonly" value="${SESSION_KEY_USER_DETAIL.hrStaffId }">
				        		<input type="text" name="staffname" value="${SESSION_KEY_USER_DETAIL.realName }" readonly="readonly" style="border:0px" class="layui-input">
				      		</div>
					    </div>
				    </div>
				    <div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label">项目名称</label>
							<div class="layui-input-inline">
								<input type="text" name="proName" value="${bizPlan.proName}" 
									style="border:0px;width:220px" readonly="readonly" class="layui-input">
								<input type="hidden" name="proCode" value="${bizPlan.proCode}">
						        <input type="hidden" name="types" value="1">
						        <input type="hidden" name="sgCityId" value="${bizPlan.sgCityId}">
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">区域公司</label>
							<div class="layui-input-inline">
								<input type="text" value="${bizPlan.orgAreaName}" id ="query-input-hrOrgAreName" style="border: 0px;width:220px" 
						 		 readonly="readonly" class="layui-input">
								<input type="hidden" name="hrOrgAreaId" value="${bizPlan.hrOrgAreaId}" id ="query-input-hrOrgAreName" style="border: 0px;width:220px" 
						 		 readonly="readonly" class="layui-input">
							</div>
						</div>
			  			<div class="layui-inline">
							<label class="layui-form-label">实施机构</label>
							<div class="layui-input-inline">
								<input type="text" value="${bizPlan.carryOrg}" id ="query-input-carryOrg" style="border: 0px;" 
									name="carryOrg" readonly="readonly" class="layui-input">
							</div>
						</div>
					</div>
				    <div class="layui-form-item">
				   		<div class="layui-inline">
							<label class="layui-form-label">项目负责人</label>
							<div class="layui-input-inline">
								<input type="text" value="${bizPlan.proLeader}" id ="query-input-proLeader" style="border: 0px;" 
									name="proLeader" readonly="readonly" class="layui-input">
							</div>
						</div>
				    	<div class="layui-inline">
							<label class="layui-form-label">工程地址</label>
							<div class="layui-input-inline">
								<input type="text" value="${bizPlan.sgCityName }" id="query-input-proCityName" style="border: 0px;" 
								readonly="readonly" class="layui-input">
							</div>
						</div>
				    </div>
		  		</div>
			</fieldset>
				<fieldset class="layui-elem-field layui-field-title fieldset" >
			  		<legend class="layui-btn layui-legend" style="text-align:left;cursor:default;">附件信息  ></legend>
					  	<div style="margin-top:20px;">
						    <div class="layui-form-item">
							    <label class="layui-form-label" style="width:350px;">支持pdf、excel、word、图片资料，可上传多个</label>
							</div>
						    <div class="layui-form-item">
							    <label class="layui-form-label">商务策划（选填）</label>
							    <div class="layui-input-block">
							    	<div class="layui-upload">
						              	<button type="button" class="layui-btn" id="1-upload-more">上传</button>
				                		<div class="layui-upload-list" id="1-upload-more-list">
				                		<c:forEach items="${bizPlan.bizPlanAtts }" var="fileAtt">
					              			<c:if test="${fileAtt.types == '01' }">
					              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
					              					<c:choose>
						              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
							              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:when>
							              				<c:otherwise>
							              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:otherwise>
					              					</c:choose>
					              					<div class="mask">
					              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
					              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
					              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtt01" ></input>
					              					</div>
					              					<p>${fileAtt.fileName}</p>
					              				</div>
					              			</c:if>
					              		</c:forEach>
				                		</div>
						            </div>
							    </div>
						  	</div>
						    <div class="layui-form-item">
							    <label class="layui-form-label">主合同（选填）</label>
							    <div class="layui-input-block">
							    	<div class="layui-upload">
						              	<button type="button" class="layui-btn" id="38-upload-more">上传</button>
				                		<div class="layui-upload-list" id="38-upload-more-list">
				                		<c:forEach items="${bizPlan.bizPlanAtts }" var="fileAtt">
					              			<c:if test="${fileAtt.types == '38' }">
					              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
					              					<c:choose>
						              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
							              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:when>
							              				<c:otherwise>
							              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:otherwise>
					              					</c:choose>
					              					<div class="mask">
					              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
					              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
					              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtt38" ></input>
					              					</div>
					              					<p>${fileAtt.fileName}</p>
					              				</div>
					              			</c:if>
					              		</c:forEach>
				                		</div>
						            </div>
							    </div>
						  	</div>
						    <div class="layui-form-item">
							    <label class="layui-form-label">两评一案（选填）</label>
							    <div class="layui-input-block">
							    	<div class="layui-upload">
						              	<button type="button" class="layui-btn" id="2-upload-more">上传</button>
				                		<div class="layui-upload-list" id="2-upload-more-list">
				                		<c:forEach items="${bizPlan.bizPlanAtts }" var="fileAtt">
					              			<c:if test="${fileAtt.types == '02' }">
					              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
					              					<c:choose>
						              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
							              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:when>
							              				<c:otherwise>
							              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:otherwise>
					              					</c:choose>
					              					<div class="mask">
					              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
					              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
					              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtt02" ></input>
					              					</div>
					              					<p>${fileAtt.fileName}</p>
					              				</div>
					              			</c:if>
					              		</c:forEach>
				                		</div>
						            </div>
							    </div>
						  	</div>
						    <div class="layui-form-item">
							    <label class="layui-form-label">招标文件（选填）</label>
							    <div class="layui-input-block">
							    	<div class="layui-upload">
						              	<button type="button" class="layui-btn" id="21-upload-more">上传</button>
				                		<div class="layui-upload-list" id="21-upload-more-list">
				                		<c:forEach items="${bizPlan.bizPlanAtts }" var="fileAtt">
					              			<c:if test="${fileAtt.types == '21' }">
					              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
					              					<c:choose>
						              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
							              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:when>
							              				<c:otherwise>
							              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:otherwise>
					              					</c:choose>
					              					<div class="mask">
					              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
					              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
					              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtt21" ></input>
					              					</div>
					              					<p>${fileAtt.fileName}</p>
					              				</div>
					              			</c:if>
					              		</c:forEach>
				                		</div>
						            </div>
							    </div>
						  	</div>
						    <div class="layui-form-item">
							    <label class="layui-form-label">投标文件（选填）</label>
							    <div class="layui-input-block">
							    	<div class="layui-upload">
						              	<button type="button" class="layui-btn" id="37-upload-more">上传</button>
				                		<div class="layui-upload-list" id="37-upload-more-list">
				                		<c:forEach items="${bizPlan.bizPlanAtts }" var="fileAtt">
					              			<c:if test="${fileAtt.types == '37' }">
					              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
					              					<c:choose>
						              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
							              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:when>
							              				<c:otherwise>
							              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:otherwise>
					              					</c:choose>
					              					<div class="mask">
					              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
					              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
					              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtt37" ></input>
					              					</div>
					              					<p>${fileAtt.fileName}</p>
					              				</div>
					              			</c:if>
					              		</c:forEach>
				                		</div>
						            </div>
							    </div>
						  	</div>
						    <div class="layui-form-item">
							    <label class="layui-form-label">最新政策（选填）</label>
							    <div class="layui-input-block">
							    	<div class="layui-upload">
						              	<button type="button" class="layui-btn" id="11-upload-more">上传</button>
				                		<div class="layui-upload-list" id="11-upload-more-list">
				                		<c:forEach items="${bizPlan.bizPlanAtts }" var="fileAtt">
					              			<c:if test="${fileAtt.types == '99' }">
					              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
					              					<c:choose>
						              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
							              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:when>
							              				<c:otherwise>
							              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
							              				</c:otherwise>
					              					</c:choose>
					              					<div class="mask">
					              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
					              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
					              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtt99" ></input>
					              					</div>
					              					<p>${fileAtt.fileName}</p>
					              				</div>
					              			</c:if>
					              		</c:forEach>
				                		</div>
						            </div>
							    </div>
						  	</div>
					  	</div>
				</fieldset>
				<div class="layui-form-item" style="position: fixed ! important; right: 30px; bottom:45%;z-index:10000;">
					<div class="layui-input-block">
			      		<button class="layui-btn layui-bg-blue layui-btn-normal layui-btn-lg  layui-btn-radius" type="button" lay-submit lay-filter="addInfo_form_submit" id="addInfo_form_submit">
			      		<i class="layui-icon layui-icon-ok layuiadmin-button-btn"></i>
			      		提交
			      		</button>
			      	</div>
			    </div>
			</form>
  		</div>
	</div>
</div>
  <script>
	//静态资源路径前缀
	var staticPath = '${fileHttpPre}';
	var stateJSON = <infopub:dicJson groupNo="A00010028" />;
	
  layui.config({
    base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'set', 'upload', 'element', 'laydate'], function(){
    var $ = layui.$
    ,form = layui.form
    ,element = layui.element
    ,laydate = layui.laydate
    ,upload = layui.upload;
    
 	// 正则校验
	form.verify({
		//验证汉字
	    CHS:[
	    	/^[\u0391-\uFFE5]+$/
	    	,'只能输入汉字'
	  	],
	  	//大于0的正整数
	  	intNumber:[
			/^[1-9]\d*$/
			,'请输入正确的数字'
	  	],
	  	//数字只能有两位小数
	  	floatNumber:[
			/^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
			,'请输入正确的数字'
	  	],
	  	//数字大于0，并只能有两位小数
	  	floatAmount:[
			/^([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
			//var pattern=/^((\d+\.\d*[1-9]\d{1})|(\d*[1-9]\d*\.\d{2}))$/; 
			,'请输入正确的数字'
	  	]
	});
	//上传附件
  	upload.render({
	      elem: '#1-upload-more'
	      ,url: basePath + '/bizPlan/uploadAtt/'
	      ,data: {
	    	  types:'01'
	    		}
	      ,multiple: true
	      ,accept: 'file'
	      ,acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf'
	   	  ,before: function(obj){ //obj参数包含的信息
	   		    layer.load(); //上传loading
	   		  }
	      ,done: function(res){
	    	  //如果上传失败
	          if(res.code > 0){
	        	  layer.closeAll('loading'); //关闭loading
	        	  return layer.msg(res.msg,{icon: 7});
	          }
	          //上传完毕
	   	  	  if(res.entity != null && res.entity.length > 0){
				for(var i in res.entity){
					var bizPlanAtt = res.entity[i];
					var arr = bizPlanAtt.split("|");
					var imgSrc = "";
					var suffix = arr[1].substring(arr[1].lastIndexOf(".")+1,arr[1].length);
					if(suffix == 'jpg' || suffix == 'png'){
						imgSrc = "${fileHttpPre}/"+arr[3];
					}else{
						imgSrc = "${ctx}/resources/images/"+suffix+".jpg";
					}
	        		$('#1-upload-more-list').append('<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''+"${fileHttpPre}"+arr[3] +'\');">查看</a><a href="javascript:void(0)" onclick="del(\''+arr[2]+'\')";>删除</a></div><p>'+arr[1]+'</p><input type="hidden" value="'+bizPlanAtt+'" id="fileAtt_'+arr[2]+'" name="fileAtt01" ></input></div> ');
				}
		  	  }
	      }
	      ,allDone: function(obj){ //当文件全部被提交后，才触发
	    	  layer.closeAll('loading'); //关闭loading
	      }
	      ,error: function(){
	    	  layer.closeAll('loading'); //关闭loading
	          //上传失败
	          layer.msg("上传失败，请稍后再试~",{icon: 7});
	        }
	    });
	//上传附件
  	upload.render({
	      elem: '#2-upload-more'
	      ,url: basePath + '/bizPlan/uploadAtt/'
	      ,data: {
	    	  types:'02'
	    		}
	      ,multiple: true
	      ,accept: 'file'
	      ,acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf'
	   	  ,before: function(obj){ //obj参数包含的信息
	   		    layer.load(); //上传loading
	   		  }
	      ,done: function(res){
	    	  //如果上传失败
	          if(res.code > 0){
	        	  layer.closeAll('loading'); //关闭loading
	        	  return layer.msg(res.msg,{icon: 7});
	          }
	          //上传完毕
	   	  	  if(res.entity != null && res.entity.length > 0){
				for(var i in res.entity){
					var bizPlanAtt = res.entity[i];
					var arr = bizPlanAtt.split("|");
					var imgSrc = "";
					var suffix = arr[1].substring(arr[1].lastIndexOf(".")+1,arr[1].length);
					if(suffix == 'jpg' || suffix == 'png'){
						imgSrc = "${fileHttpPre}/"+arr[3];
					}else{
						imgSrc = "${ctx}/resources/images/"+suffix+".jpg";
					}
	        		$('#2-upload-more-list').append('<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''+"${fileHttpPre}"+arr[3] +'\');">查看</a><a href="javascript:void(0)" onclick="del(\''+arr[2]+'\')";>删除</a></div><p>'+arr[1]+'</p><input type="hidden" value="'+bizPlanAtt+'" id="fileAtt_'+arr[2]+'" name="fileAtt02" ></input></div> ');
				}
		  	  }
	      }
	      ,allDone: function(obj){ //当文件全部被提交后，才触发
	    	  layer.closeAll('loading'); //关闭loading
	      }
	      ,error: function(){
	    	  layer.closeAll('loading'); //关闭loading
	          //上传失败
	          layer.msg("上传失败，请稍后再试~",{icon: 7});
	        }
	    });
	
	//上传附件
  	upload.render({
	      elem: '#21-upload-more'
	      ,url: basePath + '/bizPlan/uploadAtt/'
	      ,data: {
	    	  types:21
	    		}
	      ,multiple: true
	      ,accept: 'file'
	      ,acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf'
	   	  ,before: function(obj){ //obj参数包含的信息
	   		    layer.load(); //上传loading
	   		  }
	      ,done: function(res){
	    	  //如果上传失败
	          if(res.code > 0){
	        	  layer.closeAll('loading'); //关闭loading
	        	  return layer.msg(res.msg,{icon: 7});
	          }
	          //上传完毕
	   	  	  if(res.entity != null && res.entity.length > 0){
				for(var i in res.entity){
					var bizPlanAtt = res.entity[i];
					var arr = bizPlanAtt.split("|");
					var imgSrc = "";
					var suffix = arr[1].substring(arr[1].lastIndexOf(".")+1,arr[1].length);
					if(suffix == 'jpg' || suffix == 'png'){
						imgSrc = "${fileHttpPre}/"+arr[3];
					}else{
						imgSrc = "${ctx}/resources/images/"+suffix+".jpg";
					}
	        		$('#21-upload-more-list').append('<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''+"${fileHttpPre}"+arr[3] +'\');">查看</a><a href="javascript:void(0)" onclick="del(\''+arr[2]+'\')";>删除</a></div><p>'+arr[1]+'</p><input type="hidden" value="'+bizPlanAtt+'" id="fileAtt_'+arr[2]+'" name="fileAtt21" ></input></div> ');
				}
		  	  }
	      }
	      ,allDone: function(obj){ //当文件全部被提交后，才触发
	    	  layer.closeAll('loading'); //关闭loading
	      }
	      ,error: function(){
	    	  layer.closeAll('loading'); //关闭loading
	          //上传失败
	          layer.msg("上传失败，请稍后再试~",{icon: 7});
	        }
	    });
	//上传附件
  	upload.render({
	      elem: '#37-upload-more'
	      ,url: basePath + '/bizPlan/uploadAtt/'
	      ,data: {
	    	  types:37
	    		}
	      ,multiple: true
	      ,accept: 'file'
	      ,acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf'
	   	  ,before: function(obj){ //obj参数包含的信息
	   		    layer.load(); //上传loading
	   		  }
	      ,done: function(res){
	    	  //如果上传失败
	          if(res.code > 0){
	        	  layer.closeAll('loading'); //关闭loading
	        	  return layer.msg(res.msg,{icon: 7});
	          }
	          //上传完毕
	   	  	  if(res.entity != null && res.entity.length > 0){
				for(var i in res.entity){
					var bizPlanAtt = res.entity[i];
					var arr = bizPlanAtt.split("|");
					var imgSrc = "";
					var suffix = arr[1].substring(arr[1].lastIndexOf(".")+1,arr[1].length);
					if(suffix == 'jpg' || suffix == 'png'){
						imgSrc = "${fileHttpPre}/"+arr[3];
					}else{
						imgSrc = "${ctx}/resources/images/"+suffix+".jpg";
					}
	        		$('#37-upload-more-list').append('<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''+"${fileHttpPre}"+arr[3] +'\');">查看</a><a href="javascript:void(0)" onclick="del(\''+arr[2]+'\')";>删除</a></div><p>'+arr[1]+'</p><input type="hidden" value="'+bizPlanAtt+'" id="fileAtt_'+arr[2]+'" name="fileAtt37" ></input></div> ');
				}
		  	  }
	      }
	      ,allDone: function(obj){ //当文件全部被提交后，才触发
	    	  layer.closeAll('loading'); //关闭loading
	      }
	      ,error: function(){
	    	  layer.closeAll('loading'); //关闭loading
	          //上传失败
	          layer.msg("上传失败，请稍后再试~",{icon: 7});
	        }
	    });
	//上传附件
  	upload.render({
	      elem: '#38-upload-more'
	      ,url: basePath + '/bizPlan/uploadAtt/'
	      ,data: {
	    	  types:38
	    		}
	      ,multiple: true
	      ,accept: 'file'
	      ,acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf'
	   	  ,before: function(obj){ //obj参数包含的信息
	   		    layer.load(); //上传loading
	   		  }
	      ,done: function(res){
	    	  //如果上传失败
	          if(res.code > 0){
	        	  layer.closeAll('loading'); //关闭loading
	        	  return layer.msg(res.msg,{icon: 7});
	          }
	          //上传完毕
	   	  	  if(res.entity != null && res.entity.length > 0){
				for(var i in res.entity){
					var bizPlanAtt = res.entity[i];
					var arr = bizPlanAtt.split("|");
					var imgSrc = "";
					var suffix = arr[1].substring(arr[1].lastIndexOf(".")+1,arr[1].length);
					if(suffix == 'jpg' || suffix == 'png'){
						imgSrc = "${fileHttpPre}/"+arr[3];
					}else{
						imgSrc = "${ctx}/resources/images/"+suffix+".jpg";
					}
	        		$('#38-upload-more-list').append('<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''+"${fileHttpPre}"+arr[3] +'\');">查看</a><a href="javascript:void(0)" onclick="del(\''+arr[2]+'\')";>删除</a></div><p>'+arr[1]+'</p><input type="hidden" value="'+bizPlanAtt+'" id="fileAtt_'+arr[2]+'" name="fileAtt38" ></input></div> ');
				}
		  	  }
	      }
	      ,allDone: function(obj){ //当文件全部被提交后，才触发
	    	  layer.closeAll('loading'); //关闭loading
	      }
	      ,error: function(){
	    	  layer.closeAll('loading'); //关闭loading
	          //上传失败
	          layer.msg("上传失败，请稍后再试~",{icon: 7});
	        }
	    });
	//上传附件
  	upload.render({
	      elem: '#99-upload-more'
	      ,url: basePath + '/bizPlan/uploadAtt/'
	      ,data: {
	    	  types:99
	    		}
	      ,multiple: true
	      ,accept: 'file'
	      ,acceptMime: 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf'
	   	  ,before: function(obj){ //obj参数包含的信息
	   		    layer.load(); //上传loading
	   		  }
	      ,done: function(res){
	    	  //如果上传失败
	          if(res.code > 0){
	        	  layer.closeAll('loading'); //关闭loading
	        	  return layer.msg(res.msg,{icon: 7});
	          }
	          //上传完毕
	   	  	  if(res.entity != null && res.entity.length > 0){
				for(var i in res.entity){
					var bizPlanAtt = res.entity[i];
					var arr = bizPlanAtt.split("|");
					var imgSrc = "";
					var suffix = arr[1].substring(arr[1].lastIndexOf(".")+1,arr[1].length);
					if(suffix == 'jpg' || suffix == 'png'){
						imgSrc = "${fileHttpPre}/"+arr[2];
					}else{
						imgSrc = "${ctx}/resources/images/"+suffix+".jpg";
					}
	        		$('#99-upload-more-list').append('<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''+"${fileHttpPre}"+arr[3] +'\');">查看</a><a href="javascript:void(0)" onclick="del(\''+arr[2]+'\')";>删除</a></div><p>'+arr[1]+'</p><input type="hidden" value="'+bizPlanAtt+'" id="fileAtt_'+arr[2]+'" name="fileAtt99" ></input></div> ');
				}
		  	  }
	      }
	      ,allDone: function(obj){ //当文件全部被提交后，才触发
	    	  layer.closeAll('loading'); //关闭loading
	      }
	      ,error: function(){
	    	  layer.closeAll('loading'); //关闭loading
	          //上传失败
	          layer.msg("上传失败，请稍后再试~",{icon: 7});
	        }
	    });
	
   	//监听提交
  	form.on('submit(addInfo_form_submit)', function(data){
  		$("#addInfo_form_submit").removeAttr("lay-submit").removeClass("layui-bg-blue").addClass("layui-btn-disabled");
  		layer.load();
       	//提交 Ajax 成功后，静态更新表格中的数据
       	$.ajax({
           	type : 'post',
			url : basePath + '/bizPlan/save',
           	data: $('#addInfo_form').serialize(),
			success:function(result){
				if(result.success){
					layer.closeAll('loading'); //关闭loading
					layer.msg('提交单据成功~',{icon: 1});
					//两秒后关闭当前页面
					setTimeout(function(){
						/**
						 * 查找父菜单，并刷新
						 */
						var topDoc = $(window.top.document);
						var path = basePath + '/bizPlan/list';
						// 获取页面名称
						var name = topDoc.find(".layui-nav-item [lay-href^='" + path + "']").text();
						if(name == '' || name == null){
							name = '商务策划';
						}
						window.parent.layui.index.openTabsPage(path, name);
						var iframe = window.parent.layui.admin.tabsBody(window.parent.layui.admin.tabsPage.index).find(".layadmin-iframe");
						iframe[0].contentWindow.location.reload(true);
						
						/**
						 * 关闭当前页
						 */
						var currPath = basePath + '/bizPlan/toCopy';
						var layid = topDoc.find("li[lay-id^='" + currPath + "']").attr('lay-id');
						window.parent.layui.element.tabDelete('layadmin-layout-tabs', layid);//关闭当前页
				        }, 2000);
				}else{
					layer.closeAll('loading'); //关闭loading
  					$("#addInfo_form_submit").removeClass("layui-btn-disabled").addClass("layui-bg-blue").attr("lay-submit","");
					layer.msg(result.msg,{icon: 7});
			  	}
			}
       	});
   	});  
 	// data-type事件
    $('.layui-btn.layuiadmin-btn-admin').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
    });
 	
  	//新增-项目名select监听
    form.on('select(add_select_proId)', function(data){
    	$('#query-input-hrOrgAreId').val('');
    	$('#query-input-hrOrgAreName').val('');
    	$('#query-input-hrOrgProId').val('');
    	$('#query-input-hrOrgProName').val('');
    	$('#query-input-carryOrg').val('');
    	$('#query-input-proLeader').val('');
    	$('#query-input-proCityName').val('');
    	var proId = data.value;
    	if(proId==''||proId==null){
    		layer.msg('请选择项目名称',{icon: 1});
    		return;
    	}else{
    		getProContractById(proId);
    	}		
	});
  	
  });
  
   function getProContractById(id){
	   var $ = layui.$
	  	,form = layui.form
		$.ajax({
			type : "POST", //提交方式  
			url : "${ctx}/bizPlan/getProContractById",//路径  
			data : {
				"id" :id
			},//数据，这里使用的是Json格式进行传输  
			success : function(result) {//返回数据根据结果进行相应的处理 
				if(result.flag==true){
					if(result.proContractVo != null && result.proContractVo != ''){
						form.val('add_info_from',result.proContractVo); // 填充原值
						$('#query-input-proCityName').val(result.proContractVo.sgCityName);
						$('#query-input-hrOrgAreName').val(result.proContractVo.orgAreName);
						$('#query-input-hrOrgProName').val(result.proContractVo.orgProName);
						form.render();
					}
				}else{
					layer.msg('未查到合同信息~',{icon: 0});
				}
			} 
		});
   }

	//删除文件
	function del(index){
		layui.$("#fileAtt_"+index).remove();
		layui.$("#upload_img_"+index).remove();
	}
  
	//根据url查看文件
	function showImg(url){
		var openWin = window.open(url,'','left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
	}
  </script>
</body>
</html>

